0.1 By Month

1 Correlated random walk

Process Model

\[ d_{t} \sim T*d_{t-1} + Normal(0,\Sigma)\] \[ x_t = x_{t-1} + d_{t} \]

1.1 Parameters

For each individual:

\[\theta = \text{Mean turning angle}\] \[\gamma = \text{Move persistence} \]

For both behaviors process variance is: \[ \sigma_{latitude} = 0.1\] \[ \sigma_{longitude} = 0.1\]

1.2 Behavioral States

\[ \text{For each individual i}\] \[ Behavior_1 = \text{traveling}\] \[ Behavior_2 = \text{foraging}\]

\[ \alpha_{i,1,1} = \text{Probability of remaining traveling when traveling}\] \[\alpha_{i,2,1} = \text{Probability of switching from Foraging to traveling}\]

\[\begin{matrix} \alpha_{i,1,1} & 1-\alpha_{i,1,1} \\ \alpha_{i,2,1} & 1-\alpha_{i,2,1} \\ \end{matrix}\]

With the probability of switching states:

\[logit(\phi_{traveling}) = \alpha_{Behavior_{t-1}}\]

\[\phi_{foraging} = 1 - \phi_{traveling} \]

1.3 Continious tracks

The transmitter will often go dark for 10 to 12 hours, due to weather, right in the middle of an otherwise good track. The model requires regular intervals to estimate the turning angles and temporal autocorrelation. As a track hits one of these walls, call it the end of a track, and begin a new track once the weather improves. We can remove any micro-tracks that are less than three days. Specify a duration, calculate the number of tracks and the number of removed points. Iteratively.

1.3.1 After filitering

How did the filter change the extent of tracks?

sink(“Bayesian/Multi_RW.jags”) cat(" model{

#Constants
pi <- 3.141592653589

#for each if 6 argos class observation error

for(x in 1:6){

##argos observation error##
argos_prec[x,1:2,1:2] <- argos_cov[x,,]

#Constructing the covariance matrix
argos_cov[x,1,1] <- argos_sigma[x]
argos_cov[x,1,2] <- 0
argos_cov[x,2,1] <- 0
argos_cov[x,2,2] <- argos_alpha[x]
}

for(i in 1:ind){
for(g in 1:tracks[i]){

## Priors for first true location
#for lat long
y[i,g,1,1:2] ~ dmnorm(argos[i,g,1,1,1:2],argos_prec[1,1:2,1:2])

#First movement - random walk.
y[i,g,2,1:2] ~ dmnorm(y[i,g,1,1:2],iSigma)

###First Behavioral State###
state[i,g,1] ~ dcat(lambda[]) ## assign state for first obs

#Process Model for movement
for(t in 2:(steps[i,g]-1)){

#Behavioral State at time T
phi[i,g,t,1] <- alpha_mu[state[i,g,t-1],Month[i,g,t]] 
phi[i,g,t,2] <- 1-phi[i,g,t,1]
state[i,g,t] ~ dcat(phi[i,g,t,])

#Turning covariate
#Transition Matrix for turning angles
T[i,g,t,1,1] <- cos(theta[state[i,g,t]])
T[i,g,t,1,2] <- (-sin(theta[state[i,g,t]]))
T[i,g,t,2,1] <- sin(theta[state[i,g,t]])
T[i,g,t,2,2] <- cos(theta[state[i,g,t]])

#Correlation in movement change
d[i,g,t,1:2] <- y[i,g,t,] + gamma[state[i,g,t],Month[i,g,t]] * T[i,g,t,,] %*% (y[i,g,t,1:2] - y[i,g,t-1,1:2])

#Gaussian Displacement
y[i,g,t+1,1:2] ~ dmnorm(d[i,g,t,1:2],iSigma)
}

#Final behavior state
phi[i,g,steps[i,g],1] <- alpha_mu[state[i,g,steps[i,g]-1],Month[i,g,steps[i,g]-1]] 
phi[i,g,steps[i,g],2] <- 1-phi[i,g,steps[i,g],1]
state[i,g,steps[i,g]] ~ dcat(phi[i,g,steps[i,g],])

##  Measurement equation - irregular observations
# loops over regular time intervals (t)    

for(t in 2:steps[i,g]){

# loops over observed locations within interval t
for(u in 1:idx[i,g,t]){ 
zhat[i,g,t,u,1:2] <- (1-j[i,g,t,u]) * y[i,g,t-1,1:2] + j[i,g,t,u] * y[i,g,t,1:2]

#for each lat and long
#argos error
argos[i,g,t,u,1:2] ~ dmnorm(zhat[i,g,t,u,1:2],argos_prec[argos_class[i,g,t,u],1:2,1:2])
}
}
}
}
###Priors###

#Process Variance
iSigma ~ dwish(R,2)
Sigma <- inverse(iSigma)

##Mean Angle
tmp[1] ~ dbeta(10, 10)
tmp[2] ~ dbeta(10, 10)

# prior for theta in 'traveling state'
theta[1] <- (2 * tmp[1] - 1) * pi

# prior for theta in 'foraging state'    
theta[2] <- (tmp[2] * pi * 2)

##Move persistance
# prior for gamma (autocorrelation parameter) in state 1

#for each month
for (m in 1:Months){

  #Intercepts
  alpha_mu[1,m] ~ dbeta(1,1)
  alpha_mu[2,m] ~ dbeta(1,1)
  
  gamma[1,m] ~ dbeta(3,2)       ## gamma for state 1
  dev[m] ~ dbeta(1,1)           ## a random deviate to ensure that gamma[1] > gamma[2]
  gamma[2,m] <- gamma[1,m] * dev[m]
}

##Behavioral States

#Hierarchical structure across motnhs

#Variance
alpha_tau[1] ~ dt(0,1,1)I(0,)
alpha_tau[2] ~ dt(0,1,1)I(0,)

#Probability of behavior switching 
lambda[1] ~ dbeta(1,1)
lambda[2] <- 1 - lambda[1]

##Argos priors##
#longitudinal argos precision, from Jonsen 2005, 2016, represented as precision not sd

#by argos class
argos_sigma[1] <- 11.9016
argos_sigma[2] <- 10.2775
argos_sigma[3] <- 1.228984
argos_sigma[4] <- 2.162593
argos_sigma[5] <- 3.885832
argos_sigma[6] <- 0.0565539

#latitidunal argos precision, from Jonsen 2005, 2016
argos_alpha[1] <- 67.12537
argos_alpha[2] <- 14.73474
argos_alpha[3] <- 4.718973
argos_alpha[4] <- 0.3872023
argos_alpha[5] <- 3.836444
argos_alpha[6] <- 0.1081156


}"
,fill=TRUE)

sink()

##      user    system   elapsed 
##   337.529     3.925 20180.152

1.4 Chains

##             used   (Mb) gc trigger   (Mb)  max used   (Mb)
## Ncells   1512755   80.8    3886542  207.6   3886542  207.6
## Vcells 397431022 3032.2  889956371 6789.9 765594122 5841.1
##            used (Mb) gc trigger   (Mb)  max used   (Mb)
## Ncells  1348159   72    3886542  207.6   3886542  207.6
## Vcells 53212769  406  711965096 5431.9 765594122 5841.1

1.5 Change in autocorrelation over time

2 Change in transition probabilities over time

2.1 Parameter Summary

##    parameter           par       mean        lower      upper
## 1   alpha_mu alpha_mu[1,1] 0.89148610  0.813379382 0.95230902
## 2   alpha_mu alpha_mu[2,1] 0.06902732  0.022237257 0.13281403
## 3   alpha_mu alpha_mu[1,2] 0.91440407  0.862918057 0.95194997
## 4   alpha_mu alpha_mu[2,2] 0.05957062  0.033107096 0.09181736
## 5   alpha_mu alpha_mu[1,3] 0.91812786  0.872321301 0.95895730
## 6   alpha_mu alpha_mu[2,3] 0.04392333  0.024772197 0.06946068
## 7   alpha_mu alpha_mu[1,4] 0.83839337  0.759733913 0.91154048
## 8   alpha_mu alpha_mu[2,4] 0.05390102  0.021270315 0.09378220
## 9   alpha_mu alpha_mu[1,5] 0.90725130  0.813048520 0.97383379
## 10  alpha_mu alpha_mu[2,5] 0.04774076  0.017936362 0.09041703
## 11     gamma    gamma[1,1] 0.90900254  0.849480495 0.96553885
## 12     gamma    gamma[2,1] 0.30951748  0.066968554 0.56577281
## 13     gamma    gamma[1,2] 0.81296929  0.762397193 0.86223269
## 14     gamma    gamma[2,2] 0.29106393  0.145580908 0.42729593
## 15     gamma    gamma[1,3] 0.73781533  0.669270371 0.80166946
## 16     gamma    gamma[2,3] 0.32294601  0.177058514 0.45539260
## 17     gamma    gamma[1,4] 0.89656972  0.825410683 0.96235689
## 18     gamma    gamma[2,4] 0.26319044  0.099880736 0.43539423
## 19     gamma    gamma[1,5] 0.92385911  0.859276131 0.97712937
## 20     gamma    gamma[2,5] 0.48539302  0.231033788 0.71825827
## 21     theta      theta[1] 0.01466695 -0.006516048 0.03604936
## 22     theta      theta[2] 3.16031770  2.980462414 3.36305546

3 Behavioral Prediction

3.1 Spatial Prediction

3.2 By individual

3.3 Autocorrelation in behavior

4 Simulated tracks

4.1 Behavioral description

4.2 Predicted behavior duration

4.3 Duration by month

5 Proportion of states by month

6 Time between foraging bouts

7 Distance between bouts

8 Time spent in grid cell